package com.site.filter;

import com.site.utils.TextWrapper;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;

/*脏文过滤器*/
@WebFilter("/*")
public class TextFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("脏文过滤器开启");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        filterChain.doFilter(new TextWrapper((HttpServletRequest) servletRequest),servletResponse);
    }

    @Override
    public void destroy() {
        System.out.println("脏文过滤器销毁");
    }
}
